package com.lrs.java.j2se_self.lastJava;

public class TestSyncronized implements Runnable {
	private int b = 100;
	
	public static void main(String[] args){
		TestSyncronized tt = new TestSyncronized();
		Thread t = new Thread(tt);
		t.start();
		
		try{
			Thread.sleep(1000);
		}catch(InterruptedException e){
			e.printStackTrace();
		}
		tt.m2();
		System.out.println(tt.b);
	}
	
	public void run(){
		m1();
	}
	
	public synchronized void m1(){
		b = 1000;
		try {
			Thread.sleep(5000);
			//b = 1000;
			System.out.println("b1= "+ b);
		}catch(InterruptedException e){
			e.printStackTrace();
		}
	}
	public synchronized void m2() {
	//	try{
			//Thread.sleep(1000);
			//System.out.println("b = " +b);
			b = 2000;
	//	}catch(InterruptedException e){
	//		e.printStackTrace();
	//	}
	}
}
